/**
 * Licensed to CMIM,Inc. under the terms of the CMIM * Software License version 1.0.
 * See the NOTICE file distributed with this work for additional * information regarding copyright ownership.
 * ---------------------------------------------------------------------------- * Date Author Version
 * 2019/3/16 neusoft 1.0
 **/

package com.xnyzc.lhy.common.util.sign;

import com.xnyzc.lhy.common.constant.CommonConstant;
import lombok.Data;

import javax.servlet.http.HttpServletRequest;

/**
 * @author zhengxu
 */
@Data
public class RequestHeaderSign {
    private String sign;
    private String clientId;
    private String reqTime;
    private String appCode;
    private String userType;
    private String tag;

    private RequestHeaderSign() {
    }

    public static RequestHeaderSign create(HttpServletRequest request) {
        RequestHeaderSign tokenHeader = new RequestHeaderSign();

        String sign = request.getHeader(CommonConstant.REQ_HEADER_SIGN);
        String reqTime = request.getHeader(CommonConstant.REQ_HEADER_REQ_TIME);
        String clientId = request.getHeader(CommonConstant.REQ_HEADER_CLIENT_ID);
        String appCode = request.getHeader(CommonConstant.REQ_APP_CODE);
        String userType = request.getHeader(CommonConstant.REQ_HEADER_USER_TYPE);
        String tag = request.getHeader(CommonConstant.REQ_HEADER_TAG);

        tokenHeader.setSign(sign);
        tokenHeader.setReqTime(reqTime);
        tokenHeader.setClientId(clientId);
        tokenHeader.setAppCode(appCode);
        tokenHeader.setUserType(userType);
        tokenHeader.setTag(tag);

        return tokenHeader;
    }
}
